import java.util.Scanner;

/**
 * @author gao
 * @date 2025/10/14 8:38
 */

public class Main {
    public static int troublePurchase(int n, int x, int[] A, int[] B) {
        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += Math.min(A[i], B[i]);
            if (sum > x) {
                return x;
            }
        }
        return sum;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            int n = in.nextInt();
            int x = in.nextInt();
            int[] A = new int[n];
            int[] B = new int[n];
            for (int i = 0; i < n; i++) {
                A[i] = in.nextInt();
            }
            for (int i = 0; i < n; i++) {
                B[i] = in.nextInt();
            }
            System.out.println(troublePurchase(n, x, A, B));
        }
    }
}